FROM php:7.4-apache

# docker build -t thinkphp:6-7.4-apahce -f thinkphp6.Dockerfile .

LABEL image.authors="jani <liberty_linlin@qq.com>"

WORKDIR /app

# 入口设置
ENV APACHE_DOCUMENT_ROOT /app/public
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
RUN a2enmod rewrite

# 运行模式: development / production
ENV RUN_MODE development
RUN mv "$PHP_INI_DIR/php.ini-${RUN_MODE}" "$PHP_INI_DIR/php.ini"

# 安装扩展
RUN docker-php-ext-install mysqli pdo_mysql
# redis 安装不稳定，建议使用包安装
RUN curl -o redis-5.3.7.tgz http://pecl.php.net/get/redis-5.3.7.tgz \
    && pecl install redis-5.3.7.tgz \
    && docker-php-ext-enable redis \
    && rm -rf redis-5.3.7.tgz

# composer 依赖
# RUN apt update && apt install -y zip unzip git
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
RUN chmod +x /usr/bin/composer \
    && /usr/bin/composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
